package com.message.queue.rabbit.confirms;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * Created by zhangbo on 2020/7/17.
 */
@RestController
public class SendConfirmsDirectMessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/send4/{message}")
    public Object sendDirectMessage(@PathVariable(value = "message") String message) {

        String messageId = UUID.randomUUID().toString().replaceAll("-","");

//        Map<String,Object> map = new HashMap<>();
//        map.put("messageId",messageId);
//        map.put("messageData",message);
//        rabbitTemplate.convertAndSend("myDirectExchange","myDirectRouting",map);
        rabbitTemplate.convertAndSend("confirmsExchange","confirmsQueueKey",message);

        return "ok";
    }




}
